package com.heng.service.a3_beanPostProcessor接口;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class MyBeanPostProcessor implements BeanPostProcessor {

    // 方法的执行次序，先于 afterPropertiesSet
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
//        if (bean instanceof TestAop) System.out.println("postProcessAfterInitialization");
        return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
    }

    // Bean的初始化方法执行完之后，才会执行此方法
    // 处理的是全局的bean
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
//        if (bean instanceof TestAop) System.out.println("postProcessBeforeInitialization");
        return bean;
    }
}
